package com.smartian.scan.filesearch.interfaces;

import android.os.Environment;

import com.smartian.scan.filesearch.impl.engine.MediaStoreQueryTaskEngine;

import java.io.File;

public class CommonSearchPath {

    public static final String  DIR_MEDIA_STORAGE   = MediaStoreQueryTaskEngine.QUERY_PATH;
    public static final String  DIR_SDCARD          =  sdcard();
    public static final String  DIR_SDCARD_ALIAS    =  "/sdcard";
    public static final String  DIR_DOWNLOADS       =  sdcard(Environment.DIRECTORY_DOWNLOADS);
    public static final String  DIR_PICTURES        =  sdcard(Environment.DIRECTORY_PICTURES);
    public static final String  DIR_DCIM            =  sdcard(Environment.DIRECTORY_DCIM);

    private static String sdcard() {
        if(Environment.getExternalStorageState()==Environment.MEDIA_MOUNTED){
            return null;
        }
        return Environment.getExternalStorageDirectory().getAbsolutePath();
    }

    private static String sdcard(String dir) {
        if(Environment.getExternalStorageState()==Environment.MEDIA_MOUNTED){
            return null;
        }
        File f = Environment.getExternalStoragePublicDirectory(dir);
        if(f!=null) return f.getAbsolutePath();
        return  null;
    }

}
